package com.dcivision.lucene;

import java.util.HashMap;
import java.util.Map;

import org.apache.lucene.document.Field;

/**
 * Lucene index field types.
 * @author Administrator
 *
 */
public class FieldTypes {
  private static Map stores = new HashMap();
  
  private static Map indexs = new HashMap();
  
  private static Map termVectors = new HashMap();
  
  static {
    stores.put(FieldNames.UID, Field.Store.YES);
    stores.put(FieldNames.DOCUMENT_NAME_SORT, Field.Store.NO);
    stores.put(FieldNames.DOCUMENT_NAME, Field.Store.YES);
    stores.put(FieldNames.DOCUMENT_TYPE, Field.Store.YES);//Add a field. EIP-1296 lee 07/01/18
    stores.put(FieldNames.EFFECTIVE_START_DATE, Field.Store.YES);//Add a field. EIP-1129  Jim Zhou   2007/05/22
    stores.put(FieldNames.EFFECTIVE_END_DATE, Field.Store.YES);//Add a field. EIP-1129  Jim Zhou   2007/05/22
    stores.put(FieldNames.REFERENCE_NO, Field.Store.YES);
    stores.put(FieldNames.DESCRIPTION, Field.Store.COMPRESS);
    stores.put(FieldNames.ROOT_ID, Field.Store.YES);
    stores.put(FieldNames.CONTENT, Field.Store.COMPRESS);
    stores.put(FieldNames.EXTENSION, Field.Store.YES);
    stores.put(FieldNames.ITEM_SIZE, Field.Store.YES);
    stores.put(FieldNames.ITEM_STATUS, Field.Store.YES);
    stores.put(FieldNames.RECORD_STATUS, Field.Store.YES);
    stores.put(FieldNames.UPDATER_ID, Field.Store.YES);
    stores.put(FieldNames.UPDATE_DATE, Field.Store.YES);
    
    stores.put(FieldNames.DEFAULT_INDEXES, Field.Store.YES);
    stores.put(FieldNames.USER_DEFINED_INDEXES, Field.Store.YES);
    stores.put(FieldNames.USER_DEFINED_INDEX_ID, Field.Store.YES);
    stores.put(FieldNames.USER_DEFINED_INDEX_DETAIL_IDS, Field.Store.YES);
    
    indexs.put(FieldNames.UID, Field.Index.UN_TOKENIZED);
    indexs.put(FieldNames.DOCUMENT_NAME_SORT, Field.Index.UN_TOKENIZED);
    indexs.put(FieldNames.DOCUMENT_NAME, Field.Index.TOKENIZED);
    indexs.put(FieldNames.DOCUMENT_TYPE, Field.Index.UN_TOKENIZED);//Add a field. EIP-1296 lee 07/01/18
    indexs.put(FieldNames.EFFECTIVE_START_DATE, Field.Index.UN_TOKENIZED);//Add a field. EIP-1129  Jim Zhou   2007/05/22
    indexs.put(FieldNames.EFFECTIVE_END_DATE, Field.Index.UN_TOKENIZED);//Add a field. EIP-1129  Jim Zhou   2007/05/22
    indexs.put(FieldNames.REFERENCE_NO, Field.Index.TOKENIZED);
    indexs.put(FieldNames.DESCRIPTION, Field.Index.TOKENIZED);
    indexs.put(FieldNames.ROOT_ID, Field.Index.UN_TOKENIZED);
    indexs.put(FieldNames.CONTENT, Field.Index.TOKENIZED);
    indexs.put(FieldNames.EXTENSION, Field.Index.UN_TOKENIZED);
    indexs.put(FieldNames.ITEM_SIZE, Field.Index.UN_TOKENIZED);
    indexs.put(FieldNames.ITEM_STATUS, Field.Index.UN_TOKENIZED);
    indexs.put(FieldNames.RECORD_STATUS, Field.Index.UN_TOKENIZED);
    indexs.put(FieldNames.UPDATER_ID, Field.Index.UN_TOKENIZED);
    indexs.put(FieldNames.UPDATE_DATE, Field.Index.UN_TOKENIZED);
    
    indexs.put(FieldNames.DEFAULT_INDEXES, Field.Index.TOKENIZED);
    indexs.put(FieldNames.USER_DEFINED_INDEXES, Field.Index.TOKENIZED);
    indexs.put(FieldNames.USER_DEFINED_INDEX_ID, Field.Index.UN_TOKENIZED);
    indexs.put(FieldNames.USER_DEFINED_INDEX_DETAIL_IDS, Field.Index.TOKENIZED);
    
    termVectors.put(FieldNames.CONTENT, Field.TermVector.WITH_POSITIONS_OFFSETS);
  }
  
  public FieldTypes() {
    
  }
  
  public static Field.Store getStore(String fieldName) {
    Field.Store store = (Field.Store)stores.get(fieldName);
    return (store!=null?store:Field.Store.YES);
  }
  
  public static Field.Index getIndex(String fieldName) {
    Field.Index index = (Field.Index)indexs.get(fieldName);
    return (index!=null?index:Field.Index.UN_TOKENIZED);
  }
  
  public static Field.TermVector getTermVector(String fieldName) {
    Field.TermVector vector = (Field.TermVector)termVectors.get(fieldName);
    return (vector!=null?vector:Field.TermVector.YES);
  }
  
}
